package com.mf.basic.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.mf.basic.debounces.Debounce;
import com.mf.basic.services.ServiceApiLog;
import com.mf.basic.entity.DtoApiLog;
import com.mf.basic.rs.ResponseResult;
import com.mf.basic.utils.MyAssert;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * Created by Luke on 2025/3/7 16:58.
 */
@RestController
@ResponseResult
@SaCheckLogin
@RequestMapping("/apiLog")
public class ControllerApiLog implements MyAssert {

    @Resource
    private ServiceApiLog serviceApiLog;

    /**
     * 查询日志列表
     * @param params douser,startTime,endTime,operation,params,pageNum,pageSize
     * @return IPage<DtoVersion>
     */
    @Debounce
    @PostMapping("/page")
    @SaCheckPermission("log.search")
    public IPage<DtoApiLog> get(@RequestBody Map<String, Object> params) {
        pageIsNull(params);
        strIsNull(params.get("startTime"), "开始时间(yyyy-MM-dd HH:mm:ss)");
        return serviceApiLog.findPageByParams(params);
    }

}
